/******************************************************************************
 *                  Shanghai ChipON Micro-Electronic Co.,Ltd
 ******************************************************************************
 *  @File Name        : DELAY.c
 *  @Author           : ChipON AE/FAE Group
 *  @Date             : 2023-12-19
 *  @HW Version       : KF8A100Fxx
 *  @Lib Version      : V2.0.1
 *  @Description      : This file provides the software delay function
 ******************************************************************************
 *  Copyright (C) by Shanghai ChipON Micro-Electronic Co.,Ltd
 *  All rights reserved.
 *
 *  This software is copyright protected and proprietary to
 *  Shanghai ChipON Micro-Electronic Co.,Ltd.
 *****************************************************************************/
/******************************************************************************
 *  |Date        |Version  |Author       |Description
 ******************************************************************************
 *  |2023-12-25  |V2.0     |Wang Junxiong|New creat
 *****************************************************************************/

/******************************************************************************
 *                      Include Files
 *****************************************************************************/
#include "DELAY.h"
/******************************************************************************
 *                      Macro Definitions
 *****************************************************************************/

/******************************************************************************
 *                      Constants
 *****************************************************************************/

/******************************************************************************
 *                      Type definitions
 *****************************************************************************/

/******************************************************************************
 *                      Variables
 *****************************************************************************/

/******************************************************************************
 *                      Function definitions
 *****************************************************************************/

/**
 * @brief Delay n*1ms. Use the command delay for a fixed amount of time, actually the minimum time to call some empty
 * function
 *
 * @details The lower the system clock frequency, the longer the timing period, the specific crystal frequency and
 * timing period of the corresponding relationship is as follows
 * 16M-1ms
 * 8M-2ms
 * 4M-4ms
 * 2M-8ms
 * ......
 * Other cases are in the same order
 *
 * @param n_ms n*1ms
 */
void Delay_ms_loop(uint16_t n_ms)
{
    uint16_t i, j;
    for (i = 0u; i < n_ms; i++)
    {
        for (j = 0u; j < 234u; j++)
        {
            /* PRQA S 2987 1 # Delay using null function. */
            Delay_2us_loop();
        }
    }
}

/**
 * @brief Delay n*10us. Use the command delay for a fixed amount of time, actually the minimum time to call some empty
 * function
 *
 * @details The lower the system clock frequency, the longer the timing period, the specific crystal frequency and
 * timing period of the corresponding relationship is as follows
 * 16M-10us
 * 8M-20us
 * 4M-40us
 * 2M-80us
 * ......
 * Other cases are in the same order
 *
 * @param n_10us n*10us
 */
void Delay_10us_loop(uint16_t n_10us)
{
    uint16_t i;
    for (i = 0u; i < n_10us; i++)
    {
        /* PRQA S 2987 4 # Delay using null function. */
        Delay_2us_loop();
        Delay_2us_loop();
        Delay_2us_loop();
        Delay_2us_loop();
    }
}

/**
 * @brief Delay 2us. Use the instruction to delay a fixed amount of time, effectively the minimum time to call an empty
 * function.
 *
 * @details The lower the system clock frequency, the longer the timing period, the specific crystal frequency and
 * timing period of the corresponding relationship is as follows
 * 16M-2us
 * 8M-4us
 * 4M-8us
 * 2M-16us
 * ......
 * Other cases are in the same order
 */
void Delay_2us_loop(void) {}

/* EOF */
